package com.google.code.mamule.price;

import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;

@Repository
public interface PriceRepository extends CrudRepository<Price, Long> {

  @Query(
      "SELECT p FROM Price p WHERE p.date>=ALL(SELECT p2.date FROM Price p2 WHERE p.region=p2.region))")
  Iterable<Price> findLatestPrice();
}
